package com.alibaba.nacos.client.javajdk.config;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;

import java.util.Properties;

/**
 * 采用JDK的方式进行Config的管理（获取，发布，监听等）- 属于nacos-api模块下 .
 *
 * @author liyunfei
 */
public class ConfigManager {
    private static final String serverAddr = "localhost";
    private static final String dataId = "hello-tst.text";
    private static final String group = "DEFAULT_GROUP";
    
    /**
     * 获取配置.
     */
    public static void testGetConfig(){
        try {
            Properties properties = new Properties();
            properties.put("serverAddr", serverAddr);
            ConfigService configService = NacosFactory.createConfigService(properties);
            String content = configService.getConfig(dataId, group, 5000);
            System.out.println(content);
        } catch (NacosException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        testGetConfig();
    }
}
